﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.UI.WebControls.Expressions;

namespace yao.Common
{
    public static class ValidateHelper
    {
        private static Regex RegNumber = new Regex("^[0-9]+$");
        private static Regex RegNumberSign = new Regex("^[+-]?[0-9]+$");
        private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+$");
        private static Regex RegDecimalSign = new Regex("^[+-]?[0-9]+[.]?[0-9]+$"); //等价于^[+-]?\d+[.]?\d+$  
        private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$");//w 英文字母或数字的字符串，和 [a-zA-Z0-9] 语法一样   
        private static Regex RegCHZN = new Regex("[\u4e00-\u9fa5]");

        //private  static void PageError(this HtmlHelper htmlHelper,string name,string message)
        //{
        //    //((Dictionary<string, string>)htmlHelper.ViewData["BusinessFormError"]).Add(name, message);
        //}

        //public static bool IsValid(this HtmlHelper htmlHelper)
        //{
        //    //return !(((Dictionary<string, string>)htmlHelper.ViewData["BusinessFormError"]).Count > 0);
        //}

        /// <summary>
        /// 验证字符串是否为null 或者空
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        //public static void LIsNullEmpty(this HtmlHelper htmlHelper,string name,string str,string message)
        //{
        //    if (string.IsNullOrEmpty(str))
        //    {
        //        htmlHelper.PageError(name,message);
        //    }
        //}
    }
}
